package com.mz.ozy.mvp.model;

import android.content.Context;
import android.util.Log;

import com.mz.ozy.constants.Constants;
import com.mz.ozy.net.RetrofitUtils;
import com.mz.ozy.utils.JsonUtils;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class GoodsListModel {
    public Observable<ResponseBody> onSearchGood(Context context, String id, String type, String amttype, String orderBy, String orderType, String pageNo) {
        Map<String, String> maps = new HashMap<>();
        maps.put("content", id);
        maps.put("type", type);
//        if (orderBy != null && "2".equals(orderBy)) {
//            maps.put("amtType", amttype);
//        }
        maps.put("orderBy", orderBy);
        maps.put("orderType", orderType);
        maps.put("pageNo", pageNo);
        maps.put("pageSize", Constants.PageSize);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10112, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> onSearchGoodByTopic(Context context, String id, String pageNo) {
        Map<String, String> maps = new HashMap<>();
        maps.put("zid", id);
        maps.put("pageNo", pageNo);
        maps.put("pageSize", Constants.PageSize);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10122, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> getGoodsCategory(Context context) {
        Map<String, String> maps = new HashMap<>();
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10121, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> getTwoTitle(Context context, String id) {
        Map<String, String> maps = new HashMap<>();
        maps.put("id", id);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10206, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> getGoodsTopic(Context context) {
        Map<String, String> maps = new HashMap<>();
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10200, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> onSearchGoodByKey(Context context, String content, String type, String amttype, String orderBy, String orderType, String pageNo) {
        Map<String, String> maps = new HashMap<>();
        maps.put("content", content);
        maps.put("type", type);
//        if (orderBy != null && "2".equals(orderBy)) {
//            maps.put("amtType", amttype);
//        }
        maps.put("orderBy", orderBy);
        maps.put("orderType", orderType);
        maps.put("pageNo", pageNo);
        maps.put("pageSize", Constants.PageSize);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10112, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    //欧花列表数据
    public Observable<ResponseBody> getDataList(Context context, String pageNo, String orderBy, String type, String content, String orderType) {
        Map<String, String> maps = new HashMap<>();
        maps.put("pageNo", pageNo);
        maps.put("pageSize", Constants.PageSize);
        maps.put("orderBy", orderBy);
        maps.put("type", type);
        maps.put("content", content);
        maps.put("orderType", orderType);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10320, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

}
